﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PersonalAccounting.DataAccess;

namespace PersonalAccounting.Business
{
    public class MonedaFacade : IFacade<Moneda>
    {

        #region IFacade<Moneda> Members

        public bool Select(Moneda obj)
        {
            IDAO<MonedaVO> dao = new DAOMoneda();
            MonedaVO moneda = BuildMonedaVO(obj);
            return dao.Select(moneda);
        }

        public void Load(Moneda obj)
        {
            throw new NotImplementedException();
        }


        public bool Insert(Moneda obj)
        {
            IDAO<MonedaVO> dao = new DAOMoneda();
            MonedaVO moneda = BuildMonedaVO(obj);
            return dao.Insert(moneda);
        }

        public bool Update(Moneda obj)
        {
            IDAO<MonedaVO> dao = new DAOMoneda();
            MonedaVO moneda = BuildMonedaVO(obj);
            return dao.Update(moneda);
        }

        public bool Delete(Moneda obj)
        {
            IDAO<MonedaVO> dao = new DAOMoneda();
            MonedaVO moneda = BuildMonedaVO(obj);
            return dao.Delete(moneda);
        }


        public List<Moneda> GetAll()
        {
            IDAO<MonedaVO> dao = new DAOMoneda();
            List<Moneda> lista = new List<Moneda>();

            foreach (MonedaVO obj in dao.GetAll())
            {
                Moneda moneda = new Moneda(obj);
                lista.Add(moneda);
            }

            return lista;
        }

        #endregion


        #region Public Methods

        public int GetNextCode()
        {
            DAOMoneda dao = new DAOMoneda();
            return dao.GetNextCode();
        }

        #endregion

        #region Private Methods

        private MonedaVO BuildMonedaVO(Moneda obj)
        {
            return new MonedaVO(obj.Codigo, obj.Nombre, obj.Simbolo);
        }

        #endregion

    }
}